package com.bigdata.bookinfo.mapper;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class AuthorBookNumMapper extends Mapper<LongWritable, Text, Text, IntWritable> {
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String[] line = value.toString().split("\t");
        String author = line[3];
        String regex = "^[0-9]*$";
        if (author.length()==0
        ||author.length()>=20
        ||author.matches(regex)
        ||author.contains("公司")
        ||author.contains("集团")
        ||author.contains("出版社")
        ||author.contains("训练营")
        ||author.contains("工作室")){
            return;
        }
        context.write(new Text(author),new IntWritable(1));
    }
}
